﻿<!--
 Peter
 Created by: Peter Development Team
    http://peter.codeplex.com/
 
 GNU General Public License version 2 (GPLv2)
    http://peter.codeplex.com/license/**

 This code is provided on an AS IS basis, with no WARRANTIES,
 CONDITIONS or GUARANTEES of any kind.
-->
<UserControl x:Class="Peter.Ftp.View.ViewFtpOptions"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:logic="clr-namespace:Peter.Ftp.Logic"
             xmlns:icons="clr-namespace:Peter.Common.Icons;assembly=Peter.Common"
             xmlns:bc="clr-namespace:Peter.Common.BindingConverters;assembly=Peter.Common"
             xmlns:controls1="clr-namespace:Peter.Common.Controls;assembly=Peter.Common"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             d:DataContext="{d:DesignInstance logic:OptionsFtp}">
   
   <UserControl.Resources>
      <bc:NullNotEnabledConverter x:Key="_NullNotEnabled" />
   </UserControl.Resources>
   
   <Grid>
      
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto" />
         <RowDefinition Height="Auto" />
      </Grid.RowDefinitions>
      
      <GroupBox Header="Options"
                Grid.Row="0">
         <Grid Margin="10">
            <CheckBox Grid.Row="0"
                      Content="Upload files on Save (Not implemented)"
                      IsChecked="{Binding Path=UploadOnSave}" />
         </Grid>
      </GroupBox>
      
      <GroupBox Header="FTP Connections"
                Grid.Row="1">
         <Grid Margin="10">
            <Grid.ColumnDefinitions>
               <ColumnDefinition Width="150px" />
               <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Grid Grid.Column="0">
               <Grid.RowDefinitions>
                  <RowDefinition Height="*" />
                  <RowDefinition Height="Auto" />
               </Grid.RowDefinitions>
               
               <ListBox x:Name="_FtpConnections"
                        ItemsSource="{Binding Path=FtpConnections}"
                        SelectedItem="{Binding Path=SelectedConnection}"
                        DisplayMemberPath="Name">
               </ListBox>
               
               <StackPanel Grid.Row="1"
                           Margin="0,10,0,0"
                           HorizontalAlignment="Center"
                           Orientation="Horizontal">
                  <Button Command="{Binding Path=AddConnection}">
                     <StackPanel Orientation="Horizontal"
                                 Margin="4">
                        <icons:IconDisplay Icon="Plus"
                                           IconSize="Small" />
                        <TextBlock Text="Add"
                                   Margin="4,0,0,0" />
                     </StackPanel>
                  </Button>
                  <Button Command="{Binding Path=RemoveConnection}"
                          Margin="5,0,0,0">
                     <StackPanel Orientation="Horizontal"
                                 Margin="4">
                        <icons:IconDisplay Icon="Remove"
                                           IconSize="Small" />
                        <TextBlock Text="Remove"
                                   Margin="4,0,0,0" />
                     </StackPanel>
                  </Button>
               </StackPanel>
            </Grid>

            <ScrollViewer Grid.Column="1"
                          Margin="10,0,0,0"
                          HorizontalScrollBarVisibility="Auto"
                          VerticalScrollBarVisibility="Auto">
               <Grid DataContext="{Binding Path=SelectedItem, ElementName=_FtpConnections}"
                     x:Name="_GridDataDisplay"
                     IsEnabled="{Binding Path=SelectedItem, ElementName=_FtpConnections, Converter={StaticResource _NullNotEnabled}}">
                  <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="Auto" />
                     <ColumnDefinition Width="*" />
                  </Grid.ColumnDefinitions>

                  <Grid.RowDefinitions>
                     <RowDefinition Height="Auto" />
                     <RowDefinition Height="Auto" />
                     <RowDefinition Height="Auto" />
                     <RowDefinition Height="Auto" />
                     <RowDefinition Height="Auto" />
                     <RowDefinition Height="Auto" />
                     <RowDefinition Height="Auto" />
                  </Grid.RowDefinitions>

                  <TextBlock Text="Connection Name:"
                             HorizontalAlignment="Right"
                             VerticalAlignment="Center"
                             Margin="0,0,5,0"
                             Grid.Column="0"
                             Grid.Row="0" />

                  <TextBox Grid.Column="1"
                           Grid.Row="0"
                           Text="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}"
                           Margin="0,0,0,3" />

                  <TextBlock Text="Server:"
                             HorizontalAlignment="Right"
                             VerticalAlignment="Center"
                             Margin="0,0,5,0"
                             Grid.Column="0"
                             Grid.Row="1" />
                  
                  <TextBox Grid.Column="1"
                           Grid.Row="1"
                           Text="{Binding Path=Server}"
                           Margin="0,0,0,3" />

                  <TextBlock Text="Port:"
                             HorizontalAlignment="Right"
                             VerticalAlignment="Center"
                             Margin="0,0,5,0"
                             Grid.Column="0"
                             Grid.Row="2" />
                  
                  <controls1:NumericUpDown Value="{Binding Path=Port}"
                                          HorizontalAlignment="Left"
                                          Precision="0"
                                          Width="75"
                                          Margin="0,0,0,3"
                                          Grid.Column="1"
                                          Grid.Row="2" />

                  <TextBlock Text="User Name:"
                             HorizontalAlignment="Right"
                             VerticalAlignment="Center"
                             Margin="0,0,5,0"
                             Grid.Column="0"
                             Grid.Row="3" />

                  <TextBox Grid.Column="1"
                           Grid.Row="3"
                           Text="{Binding Path=UserName}"
                           Margin="0,0,0,3" />

                  <TextBlock Text="Password:"
                             HorizontalAlignment="Right"
                             VerticalAlignment="Center"
                             Margin="0,0,5,0"
                             Grid.Column="0"
                             Grid.Row="4" />

                  <StackPanel Margin="0,0,0,3"
                              Grid.Column="1"
                              Grid.Row="4"
                              HorizontalAlignment="Left"
                              Orientation="Horizontal"
                              DataContext="{Binding}">
                     <PasswordBox PasswordChanged="PasswordChanged"
                                  x:Name="_Password">
                        <PasswordBox.Resources>
                           <Style TargetType="PasswordBox">
                              <Setter Property="MinWidth"
                                      Value="150" />
                              <Style.Triggers>
                                 <DataTrigger Binding="{Binding Path=AskForPassword}"
                                              Value="True">
                                    <Setter Property="IsEnabled"
                                            Value="False" />
                                 </DataTrigger>
                              </Style.Triggers>
                           </Style>
                        </PasswordBox.Resources>
                     </PasswordBox>
                     <CheckBox IsChecked="{Binding Path=AskForPassword}"
                               VerticalAlignment="Center"
                               Content="Always ask for password"
                               Margin="5,0" />
                  </StackPanel>

                  <TextBlock Text="Timeout:"
                             HorizontalAlignment="Right"
                             VerticalAlignment="Center"
                             Margin="0,0,5,0"
                             Grid.Column="0"
                             Grid.Row="5" />

                  <StackPanel Margin="0,0,0,3"
                              Grid.Column="1"
                              Grid.Row="5"
                              HorizontalAlignment="Left"
                              Orientation="Horizontal"
                              DataContext="{Binding}">
                     <controls1:NumericUpDown Value="{Binding Path=Timeout}"
                                             Precision="0"
                                             Width="75" />
                     <TextBlock Text="seconds"
                                VerticalAlignment="Center"
                                Margin="4,0"/>
                  </StackPanel>

                  <TextBlock Text="Working Directory:"
                             HorizontalAlignment="Right"
                             VerticalAlignment="Center"
                             Margin="0,0,5,0"
                             Grid.Column="0"
                             Grid.Row="6" />

                  <TextBox Grid.Column="1"
                           Grid.Row="6"
                           Text="{Binding Path=WorkingPath}"
                           Margin="0,0,0,3" />
               </Grid>
            </ScrollViewer>
         </Grid>
      </GroupBox>
      
   </Grid>
</UserControl>
